﻿using Autofac;
using AutofacContrib.DynamicProxy2;
using ZenMoney.Core.Container.Interceptors;
using ZenMoney.Core.Services;
using Module = Autofac.Module;

namespace ZenMoney.Core.Container.Modules
{
	public class ServiceModule : Module
	{
		protected override void Load(ContainerBuilder builder)
		{
			builder.RegisterAssemblyTypes(ThisAssembly)
				.Where(x => x.IsAssignableTo<TransactionalService>())
				.AsImplementedInterfaces()
				.EnableInterfaceInterceptors()
				.InterceptedBy(typeof (TransactionalInterceptor));
		}
	}
}
